The SPLINE routine smoothly interpolates a function, Y=Y(x). The function is defined by a set of known values for Y at three or more values for the independent varable X. The X values need not be uniformly spaced. This function defines the natural cubic interpolatory spline. In deriving the cubic interpolatory it is assumed Y is cubic in the interval between two points (Y'' is a constant). It is further assumed that Y'' is zero at the end points of the function. SPLINE works well for any class of functions for which the conditions are approximately true. SPLINE uses the X, Y, and y'' values to perform the interpolation. The y'' values can be found using the SPL procedure which can be found in the same file with SPLINE
TYPE REQUIREMENTS
TYPE
FLOAT = EXTENDED or DOUBLE or REAL;
DATA = ARRAY[1..50] OF FLOAT;
FIXXED = INTEGER or LONGINT;
In addition, the procedure SPL is required.
CALLING PROCEDURE
VAR
X,F,S:DATA;
Z:FLOAT;
NDP:FIXXED;
{X - INDEPENDENT VARIABLE ARRAY}
{F - DEPENDENT VARIABLE ARRAY}
{S - F'' ARRAY}
{Z - INTERPOLATION POINT}
{NDP - NUMBER OF DATA POINTS}
SPL(X,F,S,NDP);{CALL SPL TO DETERMINE S}
READLN(Z);{READ IN THE INTERPOLATION POINT}
Y:=SPLINE(Z,X,F,S,NDP);{FIND VALUE OF Y AT Z}
WRITELN(Y);{PRINT OUT VALUE OF Y AT Z}
EXAMPLE
The example program reads the number of data points (NDP). It then reads in the data for two functions (X[1-NDP]), F1[1-NDP], and F2[1-NDP] and calls SPL for F1 and F2. The program will then read in z values for which to find the interpolated F1 and F2 values and print the values until z=X[1].
REFERENCES
Wendroff,B.: Theroretical Numerical Anaylsis, Academic Press, New York, 1966.